package com.ruoyi.business.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.TbGoodsListMapper;
import com.ruoyi.business.domain.TbGoodsList;
import com.ruoyi.business.service.ITbGoodsListService;
import com.ruoyi.common.core.text.Convert;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-04-23
 */
@Service
public class TbGoodsListServiceImpl implements ITbGoodsListService 
{
    @Autowired
    private TbGoodsListMapper tbGoodsListMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public TbGoodsList selectTbGoodsListById(Long id)
    {
        return tbGoodsListMapper.selectTbGoodsListById(id);
    }

    @Override
    public TbGoodsList selectTbGoodsListByGoodsId(Long goodsId) {
        return tbGoodsListMapper.selectTbGoodsDictByGoodsId(goodsId);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param tbGoodsList 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<TbGoodsList> selectTbGoodsListList(TbGoodsList tbGoodsList)
    {
        return tbGoodsListMapper.selectTbGoodsListList(tbGoodsList);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param tbGoodsList 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertTbGoodsList(TbGoodsList tbGoodsList)
    {
        int result = 0;
        TbGoodsList old = tbGoodsListMapper.selectTbGoodsListByGoodsId(tbGoodsList.getGoodsId());
        if (old != null) {
            tbGoodsList.setGoodsMount(old.getGoodsMount()+tbGoodsList.getGoodsMount());
            tbGoodsList.setId(old.getId());
            result = tbGoodsListMapper.updateTbGoodsList(tbGoodsList);
        }else {
            result = tbGoodsListMapper.insertTbGoodsList(tbGoodsList);
        }
        return result;
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param tbGoodsList 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateTbGoodsList(TbGoodsList tbGoodsList)
    {
        return tbGoodsListMapper.updateTbGoodsList(tbGoodsList);
    }

    /**
     * 删除【请填写功能名称】对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTbGoodsListByIds(String ids)
    {
        return tbGoodsListMapper.deleteTbGoodsListByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteTbGoodsListById(Long id)
    {
        return tbGoodsListMapper.deleteTbGoodsListById(id);
    }
}
